#ifndef NETWORKCOMMUNICATION_H
#define NETWORKCOMMUNICATION_H


#include <QObject>
#include <QByteArray>
#include <QTcpSocket>
#include <QTcpServer>

class NetworkConnect : public QObject
{
    Q_OBJECT
public:
   static NetworkConnect *connectserver();
   static void destroyThis();
   QTcpSocket *getconserver() const;
   bool isServerconnected() const;

private:
    explicit NetworkConnect(QObject *parent = nullptr);
    ~NetworkConnect();


signals:
   void user_signup(const QByteArray &);
   void user_signin(const QByteArray &);
   void getfriendslist(QByteArray);
   void forwardmsg(QByteArray);
   void findpasswd(QByteArray);
   void newclient();

private slots:
   void handle();
   void handledisconnect();
   void handleconnected();

private:
    static NetworkConnect *onlyone;
    static QTcpSocket *conserver;

    bool isConnected;
    QByteArray mess;
};

#endif // NETWORKCOMMUNICATION_H
